//#include "serialportwidget.h"
#include "hardinterfacetest.h"
#include <QLabel>
#include <QLineEdit>
#include <QComboBox>
#include <QPushButton>
#include <QGridLayout>
#include <QString>
#include <QTimer>
#include <QList>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <qdebug.h>
#include <qfile.h>
#include <QFile>
#include <sys/ioctl.h>
#include <unistd.h>
#include <QString>
#include <QNetworkInterface>
#include <QList>
#include <QFrame>
#include "InputMethod/inputmethod.h"
#include "wifi/wifi.h"
#include "weiqiantools/weiqiantools.h"
#include "desktopwidget.h"
#include <QWSServer>
#include "netsetting/netsettings.h"
#include "configargs.h"
#include "weiqiantools/weiqianfunctions.h"

//#include "checkmouse.h"
#include<QWSServer>



PleasWait::PleasWait(QWidget *parent) : QDialog(parent) {

        giflabel = new QLabel(this);
        giflabelt = new QLabel(this);
        forceclose= new QPushButton(tr("强制停止测试"));

		if(wifiorwangka)
        	giflabelt->setText(tr("正在测试WIFI......"));
        else
       		giflabelt->setText(tr("正在测试有线网......"));

		giflabelt->setStyleSheet("color:green;");
        giflabel->setContentsMargins(0,0,0,0);

		QMovie *movie = new QMovie(":/images/wai.gif");

		giflabel->setMovie(movie);
        movie->start();

		timer66 = new QTimer(this);
        timer66->start(1000);

		connect(timer66,SIGNAL(timeout()),this,SLOT(gifwait()));
        connect(forceclose,SIGNAL(clicked()),this,SLOT(close()));

        QGridLayout *tmplayoutl = new QGridLayout;

		tmplayoutl->addWidget(giflabelt, 0,0,1,1);
        tmplayoutl->addWidget(giflabel,  0,1,1,1);
        tmplayoutl->addWidget(forceclose,1,0,1,2);

		this->setLayout(tmplayoutl);
        this->setWindowFlags(Qt::FramelessWindowHint);
        this->exec();
}

void PleasWait::gifwait()
{
    timer66->stop();

	if(wifiorwangka){
       QFile file1ceshi("/tmp/wifitest.c");
       file1ceshi.open(QFile::ReadOnly);

	   QString setpath=file1ceshi.readAll();
       file1ceshi.close();

	   QString iptmpall;

	   int beganip=0;
       int stop=0;

	   for(int i=0;i<setpath.length();i++)
       {
        if(setpath[i]=='i' && setpath[i+1]=='v' && setpath[i+2]=='e' && setpath[i+3]=='d'&& setpath[i+4]==','){
            beganip=1;
            i+=5;
        }
        if(beganip && setpath[i]!='%' &&setpath[i]!=' ')
            if(!stop)
         wifikaiptmp.append(setpath[i]);
        if(setpath[i]=='%')
            stop=1;
       }
       qDebug()<<wifikaiptmp;
       iptmpall.append(tr("丢包率:"));
       iptmpall.append(wifikaiptmp);
       iptmpall.append('%');
       qDebug()<<iptmpall;
    wifikarate=wifikaiptmp.toInt();
    qDebug("wifikarate=%d",wifikarate);
    wifikacount++;
    timer66->start(1000);
    if( !(wifikaiptmp.isNull()) || (wifikacount > 30) )
        this->close();
  }
else {
       QFile file1("/tmp/wangka.c");
       file1.open(QFile::ReadOnly);
       QString setpath=file1.readAll();
       file1.close();
    QString iptmpall;
    int beganip=0;
    int stop=0;
    for(int i=0;i<setpath.length();i++)
    {
     if(setpath[i]=='i' && setpath[i+1]=='v' && setpath[i+2]=='e' && setpath[i+3]=='d'&& setpath[i+4]==','){
         beganip=1;
         i+=5;
     }
     if(beganip && setpath[i]!='%' &&setpath[i]!=' ')
         if(!stop)
      wangkaiptmp.append(setpath[i]);
     if(setpath[i]=='%')
         stop=1;
    }
    qDebug()<<wangkaiptmp;
    iptmpall.append(tr("丢包率:"));
    iptmpall.append(wangkaiptmp);
    iptmpall.append('%');
    qDebug()<<iptmpall;
    wangkarate=wangkaiptmp.toInt();
    qDebug("wangkarate=%d",wangkarate);
    wangkacount++;
    timer66->start(1000);
    if( !(wangkaiptmp.isNull()) || (wangkacount > 30) )
        this->close();
 }
}

PleasWait::~PleasWait() {

}
TmpDialog::TmpDialog(QWidget *parent) : QDialog(parent)
{
    item=0;
    item = tmpitem;
    settmp = new QLabel;
    surebutn = new QPushButton(tr("正常"));
    surebutn->setStyleSheet("color:green;");
    errorbutn = new QPushButton(tr("失败"));
    errorbutn->setStyleSheet("color:red;");
    calbutn = new QPushButton(tr("校准"));
    calbutn->setStyleSheet("color:red;");
    switch (item) {
    case 1:
        settmp->setText(tr("can测试是否正常?"));
        break;
    case 2:
        settmp->setText(tr("液晶屏测试是否正常?"));
        break;
    case 3:
        settmp->setText(tr("音频.漏光测试是否正常?"));
        break;
    case 4:
        settmp->setText(tr("触摸测试是否正常?"));
        break;
    case 5:
        settmp->setText(tr("蜂鸣器测试是否正常?"));
        break;
    case 6:
        settmp->setText(tr("背光测试是否正常?"));
        break;
    default:
        settmp->setText(tr("测试是否正常?"));
        break;
    }
	
    settmp->setStyleSheet("color:green;");
    connect(surebutn,SIGNAL(clicked()),this,SLOT(sure() ));
    connect(errorbutn,SIGNAL(clicked()),this,SLOT(error() ));
    connect(calbutn,SIGNAL(clicked()),this,SLOT(clatouch() ));
    QGridLayout *tmplayout = new QGridLayout;
  //  if(4==item)
   // tmplayout->addWidget(settmp,0,0,1,3);
 //   else
    tmplayout->addWidget(settmp,0,0,1,2);
    tmplayout->addWidget(surebutn,1,0,1,1);
    tmplayout->addWidget(errorbutn,1,1,1,1);
   // if(4==item)
  //  tmplayout->addWidget(calbutn  ,1,2,1,1);
    this->setLayout(tmplayout);
    this->setWindowFlags(Qt::FramelessWindowHint);
   // this->setGeometry(0, 0, 400, 200);
    this->exec();
}
void TmpDialog::clatouch()
{
    caltouchFlag=1;
 //   this->setCursor(Qt::BlankCursor);
 //   system("/usr/local/tslib1.4/bin/ts_calibrate");
 //   system("sync");
 //   this->setCursor(Qt::ArrowCursor);
    //    update();
   // this->repaint();
   // qDebug("this.close");
    //this->close();
    this->close();
}

void TmpDialog::sure()
{
    qDebug("sure");
    switch (item) {
    case 1:
        canSuccessFlag=1;
        break;
    case 2:
        yejingpingSuccessFlag=1;
        break;
    case 3:
        louguangSuccessFlag=1;
        break;
    case 4:
        chumoSuccessFlag=1;
        break;
    case 5:
        beefSuccessFlag=1;
        break;
    case 6:
        beiguangSuccessFlag=1;
        break;
    default:
        break;
    }
    this->close();
}
void TmpDialog::error()
{
    qDebug("error");
    switch (item) {
    case 1:
        canSuccessFlag=0;
        break;
    case 2:
        yejingpingSuccessFlag=0;
        break;
    case 3:
        louguangSuccessFlag=0;
        break;
    case 4:
        chumoSuccessFlag=0;
        break;
    case 5:
        beefSuccessFlag=0;
        break;
    case 6:
        beiguangSuccessFlag=0;
        break;
    default:
        break;
    }
    this->close();
}
TmpDialog::~TmpDialog()
{

}

TmpDialog1::TmpDialog1(QWidget *parent) : QDialog(parent)
{
    item=0;
    item = tmpitem;
    settmp = new QLabel;
    surebutn = new QPushButton(tr("是"));
    surebutn->setStyleSheet("color:green;");
    errorbutn = new QPushButton(tr("否"));
    errorbutn->setStyleSheet("color:red;");
    settmp->setText(tr("是否删除硬件检测工具?"));
    settmp->setStyleSheet("color:green;");
    connect(surebutn,SIGNAL(clicked()),this,SLOT(sure1() ));
    connect(errorbutn,SIGNAL(clicked()),this,SLOT(error1() ));
    QGridLayout *tmplayout = new QGridLayout;
    tmplayout->addWidget(settmp,0,0,1,2);
    tmplayout->addWidget(surebutn,1,0,1,1);
    tmplayout->addWidget(errorbutn,1,1,1,1);
    this->setLayout(tmplayout);
    this->setWindowFlags(Qt::FramelessWindowHint);
   // this->setGeometry(0, 0, 400, 200);
    this->exec();
}
void TmpDialog1::sure1()
{
    system("rm -f /etc/hardonetest.c");
    system("sync");
    this->close();
}
void TmpDialog1::error1()
{
    this->close();
}
TmpDialog1::~TmpDialog1()
{

}

Chumohuaban::Chumohuaban(QWidget *parent) : QDialog(parent)
{
    resize(int_WIDGET_W,int_WIDGET_H);
    xx=0;
    yy=0;
    this->setWindowFlags(Qt::FramelessWindowHint);
    this->exec();
}

void Chumohuaban::mousePressEvent(QMouseEvent *event)
{
    xx=event->pos().x();
    yy=event->pos().y();
    if (event->button() == Qt::LeftButton)
        startPos = event->pos();
     update();

}

void Chumohuaban::mouseMoveEvent(QMouseEvent *event)
{
    if (event->buttons() & Qt::LeftButton) {
        int distance = (event->pos().x() - startPos.x());
        if (distance >= 300) {
          this->close();
        }
        if (distance <= -300) {
            this->close();
               }

        }

}


void Chumohuaban::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);                                //创建一个画笔
    QPen pen;
    pen.setColor(Qt::red);
     pen.setWidth(1);
     painter.setPen(pen);
     for(int x=0;x<20;x++){
         if(x==10)
         for(int y=0;y<20;y++)
          painter.drawPoint(xx-10+x,yy-10+y);
     }

     for(int x1=0;x1<20;x1++){
          painter.drawPoint(xx-10+x1,yy);
     }

}
Chumohuaban::~Chumohuaban()
{

}


Yejjingpingd::Yejjingpingd(QWidget *parent) : QDialog(parent)
{
    count=0;
    luognagflag=0;
    resize(int_WIDGET_W,int_WIDGET_H);
    this->setWindowFlags(Qt::FramelessWindowHint);
    this->exec();
}

void Yejjingpingd::mousePressEvent(QMouseEvent *event)
{	
	 qDebug("mousePressEvent");
     update();
     if(count==7 || count==8)
         this->close();
     if(luognagflag==2)
         this->close();
}

void Yejjingpingd::paintEvent(QPaintEvent *event)
{
int x , y;
count++;
	qDebug("call paint event");

    QPainter painter(this);                                //创建一个画笔
    QPen pen;
	
    if(!louguangflagtu){
    switch (count) {
    case 1:
//        pen.setColor(Qt::red);
		painter.setBrush(QBrush(Qt::red,Qt::SolidPattern));

        break;
    case 2:
//        pen.setColor(Qt::yellow);
		painter.setBrush(QBrush(Qt::yellow,Qt::SolidPattern));

        break;
    case 3:
//        pen.setColor(Qt::green);
		painter.setBrush(QBrush(Qt::green,Qt::SolidPattern));

        break;
    case 4:
//        pen.setColor(Qt::blue);
		painter.setBrush(QBrush(Qt::blue,Qt::SolidPattern));

        break;
    case 5:
//        pen.setColor(Qt::white);
		painter.setBrush(QBrush(Qt::white,Qt::SolidPattern));

        break;
    case 6:
//        pen.setColor(Qt::gray);
		painter.setBrush(QBrush(Qt::gray,Qt::SolidPattern));

        break;
    case 7:
//        pen.setColor(Qt::black);
		painter.setBrush(QBrush(Qt::black,Qt::SolidPattern));

        break;
    default:
        break;
    }
    }
    else{
        painter.setBrush(QBrush(Qt::black,Qt::SolidPattern));
        luognagflag=2;
    }
//     pen.setWidth(1);
//     painter.setPen(pen);

	qDebug()<<"in paint int_WIDGET_W:" <<int_WIDGET_W;
	qDebug()<<"in paint int_WIDGET_H:" <<int_WIDGET_H;

/*	
     for( x=0;x<int_WIDGET_W;x++)
         for( y=0;y<int_WIDGET_H;y++)
    		painter.drawPoint(x,y);
*/
	
	painter.drawRect(0, 0, int_WIDGET_W, int_WIDGET_H);


	qDebug("end of drawPoint");

}
Yejjingpingd::~Yejjingpingd()
{

}


CeshiSettings::CeshiSettings(QWidget *parent) : JDialog(parent)
{  

   // m_canreEdit             = new QLineEdit;
    canSuccessFlag =0 ;
    yejingpingSuccessFlag =0 ;
    louguangSuccessFlag =0 ;
    beefSuccessFlag =0 ;
    beiguangSuccessFlag =0 ;
    chumoSuccessFlag=0;
    tmpitem=0;
    louguangflagtu=0;
    receive1=0;
    receive2=0;
    receive3=0;
    receive4=0;
    flag485=0;
    wifikarate=0;
    wangkarate=0;
    wifikacount=0;
    wangkacount=0;
    caltouchFlag=0;


    wifiorwangka=0;
    comtimer1 = new QTimer(this);
    comtimer2 = new QTimer(this);
    comtimer3 = new QTimer(this);
    comtimer4 = new QTimer(this);
	yejinpingQla = new QCheckBox(tr("液晶屏测试"));
	louguangQla= new QCheckBox(tr("音频.漏光测试"));
	chumopingQla= new QCheckBox(tr("触摸测试"));
	com34_485Qla =  new QCheckBox(tr("485.com34测试"));
	com12Qla =  new QCheckBox(tr("com12测试"));
	usb_sdQla = new QCheckBox(tr("sd.usb测试"));
	wifiQla= new QCheckBox(tr("wifi测试"));
	wangkaQla= new QCheckBox(tr("有线网测试"));
	beefQla =  new QCheckBox(tr("蜂鸣器测试"));
	beiguangQla =  new QCheckBox(tr("背光测试"));
	canQla =  new QCheckBox(tr("can测试"));

     yejinpingBtn = new QPushButton(tr("液晶屏测试"));
     louguangBtn= new QPushButton(tr("音频.漏光测试"));
     chumopingBtn= new QPushButton(tr("触摸测试"));
     com34_485Btn =  new QPushButton(tr("485.com34测试"));
     com12Btn =  new QPushButton(tr("com12测试"));
     usb_sdBtn = new QPushButton(tr("sd.usb测试"));
     wifiBtn= new QPushButton(tr("wifi测试"));
     wangkaBtn= new QPushButton(tr("有线网测试"));
     beefBtn =  new QPushButton(tr("蜂鸣器测试"));
     beiguangBtn =  new QPushButton(tr("背光测试"));
     canBtn =  new QPushButton(tr("can测试"));

     cpuFullBtn = new QPushButton(tr("一键CPU满载100%"));
     deleBtn =  new QPushButton(tr("全部重新检测"));
     deleBtn->setStyleSheet("color:red;");

	 
     if(1) {	 
         beiguangQla->setStyleSheet("QCheckBox::indicator {width: 15 px; height: 15 px;}QCheckBox::indicator:checked {image: url(:/image/linuxdesktop/settingsicon/checkbox.png);}");
         beiguangQla->setEnabled(false);
         canQla->setStyleSheet("QCheckBox::indicator {width: 15 px; height: 15 px;}QCheckBox::indicator:checked {image: url(:/image/linuxdesktop/settingsicon/checkbox.png);}");
         canQla->setEnabled(false);
         wangkaQla->setStyleSheet("QCheckBox::indicator {width: 15 px; height: 15 px;}QCheckBox::indicator:checked {image: url(:/image/linuxdesktop/settingsicon/checkbox.png);}");
         wangkaQla->setEnabled(false);
         beefQla->setStyleSheet("QCheckBox::indicator {width: 15 px; height: 15 px;}QCheckBox::indicator:checked {image: url(:/image/linuxdesktop/settingsicon/checkbox.png);}");
         beefQla->setEnabled(false);
         usb_sdQla->setStyleSheet("QCheckBox::indicator {width: 15 px; height: 15 px;}QCheckBox::indicator:checked {image: url(:/image/linuxdesktop/settingsicon/checkbox.png);}");
         usb_sdQla->setEnabled(false);
         wifiQla->setStyleSheet("QCheckBox::indicator {width: 15 px; height: 15 px;}QCheckBox::indicator:checked {image: url(:/image/linuxdesktop/settingsicon/checkbox.png);}");
         wifiQla->setEnabled(false);
         com12Qla->setStyleSheet("QCheckBox::indicator {width: 15 px; height: 15 px;}QCheckBox::indicator:checked {image: url(:/image/linuxdesktop/settingsicon/checkbox.png);}");
         com12Qla->setEnabled(false);
         usb_sdQla->setStyleSheet("QCheckBox::indicator {width: 15 px; height: 15 px;}QCheckBox::indicator:checked {image: url(:/image/linuxdesktop/settingsicon/checkbox.png);}");
         usb_sdQla->setEnabled(false);
     yejinpingQla->setStyleSheet("QCheckBox::indicator {width: 15 px; height: 15 px;}QCheckBox::indicator:checked {image: url(:/image/linuxdesktop/settingsicon/checkbox.png);}");
     yejinpingQla->setEnabled(false);
     louguangQla->setStyleSheet("QCheckBox::indicator {width: 15 px; height: 15 px;}QCheckBox::indicator:checked {image: url(:/image/linuxdesktop/settingsicon/checkbox.png);}");
     louguangQla->setEnabled(false);
     chumopingQla->setStyleSheet("QCheckBox::indicator {width: 15px; height: 15px;}QCheckBox::indicator:checked {image: url(:/image/linuxdesktop/settingsicon/checkbox.png);}");
     chumopingQla->setEnabled(false);
     com34_485Qla->setStyleSheet("QCheckBox::indicator {width: 15px; height: 15px;}QCheckBox::indicator:checked {image: url(:/image/linuxdesktop/settingsicon/checkbox.png);}");
     com34_485Qla->setEnabled(false);
     }

     if(1){
         bpMySerialPort1 = new SerialPort();
         m_pReadThread1 = new SerialPortReadThread();
         m_pReadThread1->HexOrChar_flag = 1;
         connect(m_pReadThread1, SIGNAL(receiveSignal(QString)), this, SLOT(receiveData1(QString)));

         bpMySerialPort2 = new SerialPort();
         m_pReadThread2 = new SerialPortReadThread();
         m_pReadThread2->HexOrChar_flag = 1;
         connect(m_pReadThread2, SIGNAL(receiveSignal(QString)), this, SLOT(receiveData2(QString)));

         bpMySerialPort3 = new SerialPort();
         m_pReadThread3 = new SerialPortReadThread();
         m_pReadThread3->HexOrChar_flag = 1;
         connect(m_pReadThread3, SIGNAL(receiveSignal(QString)), this, SLOT(receiveData3(QString)));

         bpMySerialPort4 = new SerialPort();
         m_pReadThread4 = new SerialPortReadThread();
         m_pReadThread4->HexOrChar_flag = 1;
         connect(m_pReadThread4, SIGNAL(receiveSignal(QString)), this, SLOT(receiveData4(QString)));

         connect(deleBtn, SIGNAL(clicked()), this, SLOT(deletool()));
//		 connect(cpuFullBtn, SIGNAL(clicked()), this, SLOT(cpufull()));
         connect(com12Btn, SIGNAL(clicked()), this, SLOT(com12()));
         connect(beefBtn, SIGNAL(clicked()), this, SLOT(beef()));
         connect(beiguangBtn, SIGNAL(clicked()), this, SLOT(beiguang()));
         connect(yejinpingBtn, SIGNAL(clicked()), this, SLOT(yejinping()));
         connect(louguangBtn, SIGNAL(clicked()), this, SLOT(louguang()));
         connect(chumopingBtn, SIGNAL(clicked()), this, SLOT(chumo()));
         connect(com34_485Btn, SIGNAL(clicked()), this, SLOT(com34_485()));
         connect(usb_sdBtn, SIGNAL(clicked()), this, SLOT(usb_sd()));
         connect(wangkaBtn, SIGNAL(clicked()), this, SLOT(wangka()));
         connect(wifiBtn, SIGNAL(clicked()), this, SLOT(wifi()));
         connect(canBtn, SIGNAL(clicked()), this, SLOT(can()));
         connect(comtimer1,SIGNAL(timeout()),this,SLOT(comtimer1fun()));
         connect(comtimer2,SIGNAL(timeout()),this,SLOT(comtimer2fun()));
         connect(comtimer3,SIGNAL(timeout()),this,SLOT(comtimer3fun()));
         connect(comtimer4,SIGNAL(timeout()),this,SLOT(comtimer4fun()));
     }



if(1){
    QGridLayout *pSubLayout = new QGridLayout;
    pSubLayout->addWidget(yejinpingQla,			0,  0, 1, 1);
    pSubLayout->addWidget(louguangQla,          1,  0, 1, 1);
    pSubLayout->addWidget(chumopingQla,		    2,  0, 1, 1);

	if(g_lcdsize != LCDSIZE_480x272)  
	{
    	pSubLayout->addWidget(com34_485Qla,         3,  0, 1, 1);
    	pSubLayout->addWidget(com12Qla,             5,  0, 1, 1);
    }	
    pSubLayout->addWidget(usb_sdQla,			6,  0, 1, 1);
    pSubLayout->addWidget(beiguangQla,          7,  0, 1, 1);
    pSubLayout->addWidget(wangkaQla,		    8,  0, 1, 1);

    if(g_lcdsize != LCDSIZE_1024x768) 
    {
    	pSubLayout->addWidget(beefQla,              9,  0, 1, 1);
    }	
    pSubLayout->addWidget(wifiQla,              10, 0, 1, 1);
    pSubLayout->addWidget(canQla,               11, 0, 1, 1);
    pSubLayout->addWidget(deleBtn,              12, 0, 1, 2);
//	pSubLayout->addWidget(cpuFullBtn,				12, 0, 1, 2);

	

    pSubLayout->addWidget(yejinpingBtn,			0,  1, 1, 1);
    pSubLayout->addWidget(louguangBtn,          1,  1, 1, 1);
    pSubLayout->addWidget(chumopingBtn,		    2,  1, 1, 1);

	if(g_lcdsize != LCDSIZE_480x272)
	{
	    pSubLayout->addWidget(com34_485Btn,         3,  1, 1, 1);
	    pSubLayout->addWidget(com12Btn,             5,  1, 1, 1);
	}    
    pSubLayout->addWidget(usb_sdBtn,			6,  1, 1, 1);
    pSubLayout->addWidget(beiguangBtn,          7,  1, 1, 1);
    pSubLayout->addWidget(wangkaBtn,		    8,  1, 1, 1);

    if(g_lcdsize != LCDSIZE_1024x768) 
    {
    	pSubLayout->addWidget(beefBtn,              9,  1, 1, 1);
    }
    pSubLayout->addWidget(wifiBtn,              10, 1, 1, 1);
    pSubLayout->addWidget(canBtn,               11, 1, 1, 1);
//    pSubLayout->addWidget(m_canreEdit,			12, 1, 1, 1);
    pSubLayout->setMargin(0);
    pSubLayout->setSpacing(5);

    QFrame *pFrame = new QFrame;
    pFrame->setLayout(pSubLayout);

    QGridLayout *pMainLayout = new QGridLayout;
    pMainLayout->addWidget(pFrame, 0, 0, 1, 1);
    pMainLayout->setContentsMargins(40, 15, 40, 15);
    pFrame->setObjectName("netSettingsFrame");
    this->setJLayout(pMainLayout);
    this->setJTitle(tr("硬件检测工具"));
}

}

void CeshiSettings::cpu_close()
{
	if(process)
	{
		process->close();
		delete process;
	
	}

	system("killall -9 am335x_cpuburn");

	cpu_dialog->close();
	delete cpu_dialog;
}

void CeshiSettings::readOut()
{
	qDebug("readout");

	QByteArray tmp;


	while(!process->atEnd())
	{
		tmp = process->readLine();
		

		if(QString(tmp).contains("am335x_cpuburn"))
		{
			qDebug() << QString(tmp);

			QStringList tmp1 = QString(tmp).split(' ', QString::SkipEmptyParts);
		
			#if 0
	    	for(int i=0; i<tmp1.size(); i++) 
			{ 
				qDebug() << (QString("[%1] %2").arg(i).arg(tmp1[i]));
			}
			#endif		

			cpudatalaber->setText(QString("%1").arg(tmp1[6]));
			break;
		}

	}

#if 0	
	for(int i=0; i<str.size(); i++) 
	{ 
		qDebug() << i << "=" <<str[i];
	}
#endif
}



void CeshiSettings::cpufull()
{
	cpu_dialog = new QDialog;
	QPushButton *exit_cpu_bt = new QPushButton;
	QHBoxLayout     *hLayout       = new QHBoxLayout;
	QGridLayout *tmplayout = new QGridLayout;
	QLabel *cpulabel = new QLabel("当前负荷:");
	cpudatalaber = new QLabel;
	process = new QProcess;

  	system("/usrfs/qtapp/am335x_cpuburn &");
  
	QStringList arguments;
	QString cmd("top");
	arguments << "-d" << "1";      //dd if=/dev/zero of=/dev/null
	
	
	qDebug("cpufull");

	hLayout->addWidget(cpulabel);
	hLayout->addWidget(cpudatalaber);

	
	connect(exit_cpu_bt, SIGNAL(clicked()), this, SLOT(cpu_close()));
	connect(process,SIGNAL(readyRead()),this,SLOT(readOut()));

	
	exit_cpu_bt->setText("退出");
	cpudatalaber->setText("100%");

	process->start(cmd, arguments);
	

	tmplayout->addLayout(hLayout, 		0,0,2,1);
	tmplayout->addWidget(exit_cpu_bt, 	2,0,1,1);
	cpu_dialog->setLayout(tmplayout);
	cpu_dialog->exec();

#if 0
	if (!process->waitForStarted())
    {
       	QMessageBox::information(NULL, tr("警告"), tr("打开进程失败"));
       
    }
#endif



}

void CeshiSettings:: comtimer1fun()
{ 
    if(!receive1){
            QDialog * setdialog = new QDialog;
            QLabel * settmp = new QLabel;//发收

			settmp->setText(tr("(com2发) -> (com1收)测试失败"));

			if(flag485)
            settmp->setText(tr("485 -> (com2发) -> (com1收)测试失败"));

			settmp->setStyleSheet("color:red;");

			QTimer*timer = new QTimer(setdialog);

			timer->start(1000);
            connect(timer,SIGNAL(timeout()),setdialog,SLOT(close()));

			QGridLayout *tmplayout = new QGridLayout;
            tmplayout->addWidget(settmp,0,0,1,1);
            setdialog->setLayout(tmplayout);
            setdialog->setWindowFlags(Qt::FramelessWindowHint);
            setdialog->exec();
        }else{
        QDialog * setdialog = new QDialog;
        QLabel * settmp = new QLabel;//发收
        settmp->setText(tr("(com2发) -> (com1收)测试成功"));
        if(flag485)
        settmp->setText(tr("485 -> (com2发) -> (com1收)测试成功"));
        settmp->setStyleSheet("color:green;");
        QTimer*timer = new QTimer(setdialog);
        timer->start(1000);
        connect(timer,SIGNAL(timeout()),setdialog,SLOT(close()));
        QGridLayout *tmplayout = new QGridLayout;
        tmplayout->addWidget(settmp,0,0,1,1);
        setdialog->setLayout(tmplayout);
        setdialog->setWindowFlags(Qt::FramelessWindowHint);
        setdialog->exec();
    }

    comtimer1->stop();
    receive1=0;
}
void CeshiSettings:: comtimer2fun()
{
    if(!receive2){
            QDialog * setdialog = new QDialog;
            QLabel * settmp = new QLabel;//发收
            settmp->setText(tr("(com1发) -> (com2收)测试失败"));
            if(flag485)
            settmp->setText(tr("485 -> (com1发) -> (com2收)测试失败"));
            settmp->setStyleSheet("color:red;");
            QTimer*timer = new QTimer(setdialog);
            timer->start(1000);
            connect(timer,SIGNAL(timeout()),setdialog,SLOT(close()));
            QGridLayout *tmplayout = new QGridLayout;
            tmplayout->addWidget(settmp,0,0,1,1);
            setdialog->setLayout(tmplayout);
            setdialog->setWindowFlags(Qt::FramelessWindowHint);
            setdialog->exec();
        }else{
        QDialog * setdialog = new QDialog;
        QLabel * settmp = new QLabel;//发收
        settmp->setText(tr("(com1发) -> (com2收)测试成功"));
        if(flag485)
        settmp->setText(tr("485 -> (com1发) -> (com2收)测试成功"));
        settmp->setStyleSheet("color:green;");
        QTimer*timer = new QTimer(setdialog);
        timer->start(1000);
        connect(timer,SIGNAL(timeout()),setdialog,SLOT(close()));
        QGridLayout *tmplayout = new QGridLayout;
        tmplayout->addWidget(settmp,0,0,1,1);
        setdialog->setLayout(tmplayout);
        setdialog->setWindowFlags(Qt::FramelessWindowHint);
        setdialog->exec();
    }

    comtimer2->stop();
    receive2=0;
}
void CeshiSettings:: comtimer3fun()
{
    if(!receive3){
            QDialog * setdialog = new QDialog;
            QLabel * settmp = new QLabel;//发收
            settmp->setText(tr("(com4发) -> (com3收)测试失败"));
            settmp->setStyleSheet("color:red;");
            QTimer*timer = new QTimer(setdialog);
            timer->start(1000);
            connect(timer,SIGNAL(timeout()),setdialog,SLOT(close()));
            QGridLayout *tmplayout = new QGridLayout;
            tmplayout->addWidget(settmp,0,0,1,1);
            setdialog->setLayout(tmplayout);
            setdialog->setWindowFlags(Qt::FramelessWindowHint);
            setdialog->exec();
        }else{
        QDialog * setdialog = new QDialog;
        QLabel * settmp = new QLabel;//发收
        settmp->setText(tr("(com4发) -> (com3收)测试成功"));
        settmp->setStyleSheet("color:green;");
        QTimer*timer = new QTimer(setdialog);
        timer->start(1000);
        connect(timer,SIGNAL(timeout()),setdialog,SLOT(close()));
        QGridLayout *tmplayout = new QGridLayout;
        tmplayout->addWidget(settmp,0,0,1,1);
        setdialog->setLayout(tmplayout);
        setdialog->setWindowFlags(Qt::FramelessWindowHint);
        setdialog->exec();
    }

    comtimer3->stop();
    receive3=0;
}
void CeshiSettings:: comtimer4fun()
{
    if(!receive4){
            QDialog * setdialog = new QDialog;
            QLabel * settmp = new QLabel;//发收
            settmp->setText(tr("(com3发) -> (com4收)测试失败"));
            settmp->setStyleSheet("color:red;");
            QTimer*timer = new QTimer(setdialog);
            timer->start(1000);
            connect(timer,SIGNAL(timeout()),setdialog,SLOT(close()));
            QGridLayout *tmplayout = new QGridLayout;
            tmplayout->addWidget(settmp,0,0,1,1);
            setdialog->setLayout(tmplayout);
            setdialog->setWindowFlags(Qt::FramelessWindowHint);
            setdialog->exec();
        }else{
        QDialog * setdialog = new QDialog;
        QLabel * settmp = new QLabel;//发收
        settmp->setText(tr("(com3发) -> (com4收)测试成功"));
        settmp->setStyleSheet("color:green;");
        QTimer*timer = new QTimer(setdialog);
        timer->start(1000);
        connect(timer,SIGNAL(timeout()),setdialog,SLOT(close()));
        QGridLayout *tmplayout = new QGridLayout;
        tmplayout->addWidget(settmp,0,0,1,1);
        setdialog->setLayout(tmplayout);
        setdialog->setWindowFlags(Qt::FramelessWindowHint);
        setdialog->exec();
    }
    comtimer4->stop();
    receive4=0;
}

void CeshiSettings::deletool()
{
#if 0
    TmpDialog1 beefDialog1 ;
    beefDialog1.show();
#endif
	

	yejinpingQla->setChecked(false); 
	louguangQla->setChecked(false); 
	chumopingQla->setChecked(false); 
	com34_485Qla->setChecked(false); 
	com12Qla->setChecked(false); 
	usb_sdQla->setChecked(false); 
	wifiQla->setChecked(false); 
	wangkaQla->setChecked(false); 
	beefQla->setChecked(false); 
	beiguangQla->setChecked(false); 
	canQla->setChecked(false);

}


void CeshiSettings::yejinping()
{
	qDebug("yejinping start");

	Yejjingpingd yejingpingQDialog ;
    yejingpingQDialog.show();
	qDebug("yejinping end");

    tmpitem=2;
    TmpDialog yejingpingbeefDialog ;
    yejingpingbeefDialog.show();
    if(yejingpingSuccessFlag)
        yejinpingQla->setChecked(true);
    else
        yejinpingQla->setChecked(false);
}

void CeshiSettings::louguang()
{
    louguangflagtu=1;
    system("madplay -Q -m /usrfs/qtapp/music/1.mp3 &");
    Yejjingpingd yejingpinglouguangQDialog ;
    yejingpinglouguangQDialog.show();

    tmpitem=3;
    TmpDialog beefDialog ;
    beefDialog.show();
    if(louguangSuccessFlag)
        louguangQla->setChecked(true);
    else
        louguangQla->setChecked(false);
        louguangflagtu=0;
    system("killall -9 madplay");
}

#if 0
void CeshiSettings::com34_485()
{
    com34_485Qla->setChecked(false);
    receive1=receive2=receive3=receive4=0;
    flag485=1;

	if(!WeiqianFunctions::Test("COM2", "COM1"))  //COM2自发COM1
			receive1 = 1;
	comtimer1->start(1000);
	
	if(!WeiqianFunctions::Test("COM1", "COM2"))
			receive2 = 1;
    comtimer2->start(2000);

	if(!WeiqianFunctions::Test("COM3", "COM4"))
			receive3 = 1;
    comtimer3->start(3000);

	if(!WeiqianFunctions::Test("COM4", "COM3"))
			receive4 = 1;
    comtimer4->start(4000);

	qDebug("%d %d %d %d\n", receive1, receive2, receive3, receive4);
	

	if(receive1 && receive2 && receive3 && receive4)
	{
		com34_485Qla->setChecked(true);
	}
		
	

}
#endif

#if 1
void CeshiSettings::uart_1234_result()
{
	QString flag1 = pro_uart_1234->readLine();
	QString flag2 = pro_uart_1234->readLine();
	QString flag3 = pro_uart_1234->readLine();
	QString flag4 = pro_uart_1234->readLine();

	qDebug() << flag1;
	qDebug() << flag2;
	qDebug() << flag3;
	qDebug() << flag4;



	qDebug() << flag1.mid(6, 1);
	qDebug() << flag2.mid(6, 1);
	qDebug() << flag3.mid(6, 1);
	qDebug() << flag4.mid(6, 1);

	if(flag1.mid(6, 1).toInt() == 1)  //COM2自发COM1
				receive1 = 1;
		comtimer1->start(1000);
		
		if(flag2.mid(6, 1).toInt() == 1)
				receive2 = 1;
		comtimer2->start(2000);
	
		if(flag3.mid(6, 1).toInt() == 1)
				receive3 = 1;
		comtimer3->start(3000);
	
		if(flag4.mid(6, 1).toInt() == 1)
				receive4 = 1;
		comtimer4->start(4000);

	qDebug("%d %d %d %d\n", receive1, receive2, receive3, receive4);
	

	if(receive1 && receive2 && receive3 && receive4)
	{
		com34_485Qla->setChecked(true);
	}

}


void CeshiSettings::com34_485()
{
	com34_485Qla->setChecked(false);
	receive1=receive2=receive3=receive4=0;
	flag485 = 1;

	pro_uart_1234 = new QProcess(this);
		
	QStringList arguments;
	QString cmd("wq_uart");
	
	

//	connect(pro_uart, SIGNAL(readyRead()), this, SLOT(uart_check()));
	connect(pro_uart_1234, SIGNAL(finished(int)), this, SLOT(uart_1234_result()));



	pro_uart_1234->start(cmd, arguments);
}

#endif

#if 0
void CeshiSettings::com12()
{
    flag485=0;
    receive1=receive2=receive3=receive4=0;

    com12Qla->setChecked(false);

	if(!WeiqianFunctions::Test("COM2", "COM1"))  //COM2自发COM1
		receive1 = 1;

	if(!WeiqianFunctions::Test("COM1", "COM2"))
		receive2 = 1;
	
	comtimer1->start(2000);
    comtimer2->start(1000);

	if(receive1 && receive2)
		com12Qla->setChecked(true);
	


}
#endif

void CeshiSettings::uart_12_result()
{
	

	QString flag1 = pro_uart_12->readLine();
	QString flag2 = pro_uart_12->readLine();

	qDebug() << flag1;
	qDebug() << flag2;

	qDebug() << flag1.mid(6, 1);
	qDebug() << flag2.mid(6, 1);
	
	if(flag1.mid(6, 1).toInt() == 1)  //COM2自发COM1
				receive1 = 1;
		
		
	if(flag2.mid(6, 1).toInt() == 1)
				receive2 = 1;

	comtimer2->start(2000);
	comtimer1->start(1000);

	qDebug("%d %d\n", receive1, receive2);
	

	if(receive1 && receive2)
		com12Qla->setChecked(true);



}

void CeshiSettings::com12()
{
	

    flag485=0;
    receive1=receive2=receive3=receive4=0;

    com12Qla->setChecked(false);

	QStringList argv;
	pro_uart_12 = new QProcess(this);
	
	QString cmd("wq_uart");
	
	connect(pro_uart_12, SIGNAL(finished(int)), this, SLOT(uart_12_result()));

	pro_uart_12->start(cmd, argv);

}


void CeshiSettings::receiveData1(const QString str)
{
	qDebug() << "[1]:" << str;
   if(str.contains("weiqian22weiqian")) {
          receive1 = 1;
   }
   if( (receive1) && (receive2) && (!flag485) ){
     //  sleep(1);
       com12Qla->setChecked(true);
       comtimer1->stop();
      // comtimer1->start(500);
       comtimer2->stop();
       QDialog * setdialog = new QDialog;
       QLabel * settmp = new QLabel;//发收
     //  settmp->setText(tr("(com2发) -> (com1收)测试成功"));
       settmp->setText(tr("COM1.2测试成功"));
       settmp->setStyleSheet("color:green;");
       QTimer*timer = new QTimer(setdialog);
       timer->start(1000);
       connect(timer,SIGNAL(timeout()),setdialog,SLOT(close()));
       QGridLayout *tmplayout = new QGridLayout;
       tmplayout->addWidget(settmp,0,0,1,1);
       setdialog->setLayout(tmplayout);
       setdialog->setWindowFlags(Qt::FramelessWindowHint);
       setdialog->exec();
   }
   else{
          /* if(receive1){
                   QDialog * setdialog11 = new QDialog;
                   QLabel * settmp11 = new QLabel;//发收
                   settmp11->setText(tr("(com2发) -> (com1收)测试成功"));
                   settmp11->setStyleSheet("color:green;");
                   QTimer*timer11 = new QTimer(setdialog11);
                   timer11->start(1000);
                   connect(timer11,SIGNAL(timeout()),setdialog11,SLOT(close()));
                   QGridLayout *tmplayout11 = new QGridLayout;
                   tmplayout11->addWidget(settmp11,0,0,1,1);
                   setdialog11->setLayout(tmplayout11);
                   setdialog11->setWindowFlags(Qt::FramelessWindowHint);
                   setdialog11->exec();
               }
               else{
                   QDialog * setdialog12 = new QDialog;
                   QLabel * settmp12 = new QLabel;//发收
                   settmp12->setText(tr("(com2发) -> (com1收)测试失败"));
                   settmp12->setStyleSheet("color:red;");
                   QTimer*timer12 = new QTimer(setdialog12);
                   timer12->start(1000);
                   connect(timer12,SIGNAL(timeout()),setdialog12,SLOT(close()));
                   QGridLayout *tmplayout12 = new QGridLayout;
                   tmplayout12->addWidget(settmp12,0,0,1,1);
                   setdialog12->setLayout(tmplayout12);
                   setdialog12->setWindowFlags(Qt::FramelessWindowHint);
                   setdialog12->exec();
               }*/
     /*  QDialog * setdialog12 = new QDialog;
       QLabel * settmp12 = new QLabel;//发收
       settmp12->setText(tr("com12测试失败"));
       settmp12->setStyleSheet("color:red;");
       QTimer*timer12 = new QTimer(setdialog12);
       timer12->start(1000);
       connect(timer12,SIGNAL(timeout()),setdialog12,SLOT(close()));
       QGridLayout *tmplayout12 = new QGridLayout;
       tmplayout12->addWidget(settmp12,0,0,1,1);
       setdialog12->setLayout(tmplayout12);
       setdialog12->setWindowFlags(Qt::FramelessWindowHint);
       setdialog12->exec();*/
   }
    this->repaint();
   if( (receive1) && (receive2) && (receive3) && (receive4) ){
      // sleep(1);
       com34_485Qla->setChecked(true);
   }
}
void CeshiSettings::receiveData2(const QString str)
{
    qDebug() << "[2]:" << str;
   if(str.contains("weiqian11weiqian")) {
          receive2 = 1;
   }
   if( (receive1) && (receive2) && (!flag485) ) {
     //  sleep(1);
       comtimer1->stop();
      // comtimer1->start(500);
       comtimer2->stop();
       QDialog * setdialog = new QDialog;
       QLabel * settmp = new QLabel;//发收
     //  settmp->setText(tr("(com2发) -> (com1收)测试成功"));
       settmp->setText(tr("COM1.2测试成功"));
       settmp->setStyleSheet("color:green;");
       QTimer*timer = new QTimer(setdialog);
       timer->start(1000);
       connect(timer,SIGNAL(timeout()),setdialog,SLOT(close()));
       QGridLayout *tmplayout = new QGridLayout;
       tmplayout->addWidget(settmp,0,0,1,1);
       setdialog->setLayout(tmplayout);
       setdialog->setWindowFlags(Qt::FramelessWindowHint);
       setdialog->exec();
       com12Qla->setChecked(true);
   }
   else{
          /* if(receive2){
                   QDialog * setdialog21 = new QDialog;
                   QLabel * settmp21 = new QLabel;//发收
                   settmp21->setText(tr("(com1发) -> (com2收)测试成功"));
                   settmp21->setStyleSheet("color:green;");
                   QTimer*timer21 = new QTimer(setdialog21);
                   timer21->start(1000);
                   connect(timer21,SIGNAL(timeout()),setdialog21,SLOT(close()));
                   QGridLayout *tmplayout21 = new QGridLayout;
                   tmplayout21->addWidget(settmp21,0,0,1,1);
                   setdialog21->setLayout(tmplayout21);
                   setdialog21->setWindowFlags(Qt::FramelessWindowHint);
                   setdialog21->exec();
               }
               else{
                   QDialog * setdialog22 = new QDialog;
                   QLabel * settmp22 = new QLabel;//发收
                   settmp22->setText(tr("(com1发) -> (com2收)测试失败"));
                   settmp22->setStyleSheet("color:red;");
                   QTimer*timer22 = new QTimer(setdialog22);
                   timer22->start(1000);
                   connect(timer22,SIGNAL(timeout()),setdialog22,SLOT(close()));
                   QGridLayout *tmplayout22 = new QGridLayout;
                   tmplayout22->addWidget(settmp22,0,0,1,1);
                   setdialog22->setLayout(tmplayout22);
                   setdialog22->setWindowFlags(Qt::FramelessWindowHint);
                   setdialog22->exec();
               }*/

    }
   if( (receive1) && (receive2) && (receive3) && (receive4) ) {
      // sleep(1);
       com34_485Qla->setChecked(true);
   }
}
void CeshiSettings::receiveData3(const QString str)
{
   qDebug() << "[3]:" << str;


   if(str.contains("weiqian4")) {
          receive3=1;
   }
   if( (receive1) && (receive2) && (receive3) && (receive4) ){
       comtimer1->stop();
      // comtimer1->start(500);
       comtimer2->stop();
     //  comtimer2->start(1000);
       comtimer3->stop();
     //  comtimer3->start(1500);
       comtimer4->stop();
    //   comtimer4->start(2000);

       QDialog * setdialog = new QDialog;
       QLabel * settmp = new QLabel;//发收
     //  settmp->setText(tr("(com2发) -> (com1收)测试成功"));
       settmp->setText(tr("485.COM1.2.3.4测试成功"));
       settmp->setStyleSheet("color:green;");
       QTimer*timer = new QTimer(setdialog);
       timer->start(1000);
       connect(timer,SIGNAL(timeout()),setdialog,SLOT(close()));
       QGridLayout *tmplayout = new QGridLayout;
       tmplayout->addWidget(settmp,0,0,1,1);
       setdialog->setLayout(tmplayout);
       setdialog->setWindowFlags(Qt::FramelessWindowHint);
       setdialog->exec();
       com34_485Qla->setChecked(true);
   }
   else {
   /*    if((!receive1) && (!receive2)) {
       QDialog * setdialog12 = new QDialog;
       QLabel * settmp12 = new QLabel;//发收
       settmp12->setText(tr("com34测试失败"));
       settmp12->setStyleSheet("color:red;");
       QTimer*timer12 = new QTimer(setdialog12);
       timer12->start(1000);
       connect(timer12,SIGNAL(timeout()),setdialog12,SLOT(close()));
       QGridLayout *tmplayout12 = new QGridLayout;
       tmplayout12->addWidget(settmp12,0,0,1,1);
       setdialog12->setLayout(tmplayout12);
       setdialog12->setWindowFlags(Qt::FramelessWindowHint);
       setdialog12->exec();
       }
       if((!receive3) && (!receive4)) {
       QDialog * setdialog12 = new QDialog;
       QLabel * settmp12 = new QLabel;//发收
       settmp12->setText(tr("485测试失败"));
       settmp12->setStyleSheet("color:red;");
       QTimer*timer12 = new QTimer(setdialog12);
       timer12->start(1000);
       connect(timer12,SIGNAL(timeout()),setdialog12,SLOT(close()));
       QGridLayout *tmplayout12 = new QGridLayout;
       tmplayout12->addWidget(settmp12,0,0,1,1);
       setdialog12->setLayout(tmplayout12);
       setdialog12->setWindowFlags(Qt::FramelessWindowHint);
       setdialog12->exec();
       }*/
   }
}
void CeshiSettings::receiveData4(const QString str)
{
	qDebug() << "[4]:" << str;

   if(str.contains("weiqian3")) {
          receive4=1;
   }
   if( (receive1) && (receive2) && (receive3) && (receive4) ) {
   //    sleep(1);
       comtimer1->stop();
      // comtimer1->start(500);
       comtimer2->stop();
     //  comtimer2->start(1000);
       comtimer3->stop();
     //  comtimer3->start(1500);
       comtimer4->stop();
    //   comtimer4->start(2000);

       QDialog * setdialog = new QDialog;
       QLabel * settmp = new QLabel;//发收
     //  settmp->setText(tr("(com2发) -> (com1收)测试成功"));
       settmp->setText(tr("485.COM1.2.3.4测试成功"));
       settmp->setStyleSheet("color:green;");
       QTimer*timer = new QTimer(setdialog);
       timer->start(1000);
       connect(timer,SIGNAL(timeout()),setdialog,SLOT(close()));
       QGridLayout *tmplayout = new QGridLayout;
       tmplayout->addWidget(settmp,0,0,1,1);
       setdialog->setLayout(tmplayout);
       setdialog->setWindowFlags(Qt::FramelessWindowHint);
       setdialog->exec();
       com34_485Qla->setChecked(true);
   }
}


void CeshiSettings::chumo()
{

    Chumohuaban tmpchumo;
    tmpchumo.show();
    tmpitem=4;
    TmpDialog chumoDialog ;
    chumoDialog.show();
    if(chumoSuccessFlag)
    chumopingQla->setChecked(true);
    else
    chumopingQla->setChecked(false);
/*
    if(1){
        yejinpingBtn->setVisible(false); ;
        louguangBtn->setVisible(false);;
        chumopingBtn->setVisible(false);;
        com34_485Btn->setVisible(false);;
        com12Btn->setVisible(false); ;
        usb_sdBtn ->setVisible(false);;
        wifiBtn->setVisible(false);;
        wangkaBtn->setVisible(false);;
        beefBtn->setVisible(false);;
        beiguangBtn->setVisible(false);;
        canBtn->setVisible(false);;
        deleBtn->setVisible(false);;
    }

  //  this->repaint();
    system("/usr/local/tslib1.4/bin/ts_calibrate");
    system("sync");

    if(1){
        yejinpingBtn->setVisible(true); ;
        louguangBtn->setVisible(true);;
        chumopingBtn->setVisible(true);;
        com34_485Btn->setVisible(true);;
        com12Btn->setVisible(true); ;
        usb_sdBtn ->setVisible(true);;
        wifiBtn->setVisible(true);;
        wangkaBtn->setVisible(true);;
        beefBtn->setVisible(true);;
        beiguangBtn->setVisible(true);;
        canBtn->setVisible(true);;
        deleBtn->setVisible(true);;
    }
 //   this->setCursor(Qt::ArrowCursor);
     //   update();
   // ceshichumo=1;
   // QWSServer::setCursorVisible(true);
  //  this->setCursor(Qt::CrossCursor);*/
   /* tmpitem=4;
    TmpDialog chumoDialog ;
    chumoDialog.show();
    if(chumoSuccessFlag)
    chumopingQla->setChecked(true);
    else
    chumopingQla->setChecked(false); */
}

#if 0
void CeshiSettings::usb_sd()
{
// /mnt/sdcard/sd
    int sdflag=0;
    int usbflag1=0;
    int usbflag2=0;
    int usbflag3=0;
    int i=0;
    int ij=0;
    QString setpathsd;

	usb_sdQla->setChecked(0);

	if(1){ //sdcard
	    system("rm -f /media/sd-mmcblk0p1/sdceshi.c");

		QFile filesd("/media/sd-mmcblk0p1/sdceshi.c");
	    filesd.open(QFile::WriteOnly);
	    QTextStream s(&filesd);
	    s<<"wq_hard_test_sd";
	    filesd.close();

		QFile file2("/media/sd-mmcblk0p1/sdceshi.c");
	    file2.open(QFile::ReadOnly);

		QString setpathsd=file2.readAll();

		if(setpathsd.contains("wq_hard_test_sd")){
		    sdflag=1;

			QDialog * setdialog = new QDialog;
		    QLabel * settmp = new QLabel;

			settmp->setText(tr("SD测试成功"));
		    settmp->setStyleSheet("color:green;");

			QTimer*timer = new QTimer(setdialog);
		    timer->start(600);
		    connect(timer,SIGNAL(timeout()),setdialog,SLOT(close()));

			QFile::remove("/media/sd-mmcblk0p1/sdceshi.c");   

			QGridLayout *tmplayout = new QGridLayout;

			tmplayout->addWidget(settmp,0,0,1,1);
		    setdialog->setLayout(tmplayout);
		    setdialog->setWindowFlags(Qt::FramelessWindowHint);
		    setdialog->exec();
    	}else{
		    sdflag=0;

			QDialog * setdialog = new QDialog;
		    QLabel * settmp = new QLabel;

			settmp->setText(tr("SD测试失败"));
		    settmp->setStyleSheet("color:red;");

			QTimer*timer = new QTimer(setdialog);
		    timer->start(600);
		    connect(timer,SIGNAL(timeout()),setdialog,SLOT(close()));

			QGridLayout *tmplayout = new QGridLayout;

			tmplayout->addWidget(settmp,0,0,1,1);
		    setdialog->setLayout(tmplayout);
		    setdialog->setWindowFlags(Qt::FramelessWindowHint);
		    setdialog->exec();
	    }
    }

    if(1){
    // /media/usbdisk
        system("rm -f /tmp/usbceshi.c");
        system("sync");
        system("ls /media/ | grep usb > /tmp/usbceshi.c");
        system("sync");

		QString tmpj;
        QFile fileusbnamej("/tmp/usbceshi.c");

		fileusbnamej.open(QFile::ReadOnly);
        while(!fileusbnamej.atEnd()) {
            tmpj=(fileusbnamej.readLine());
			if((tmpj.contains("usb"))  && !(tmpj.contains("mmc"))) //防止SD卡同时插入
            	ij++;
            qDebug("ij:%d", ij);
        }
		
        fileusbnamej.close();
		
        QFile fileusbname("/tmp/usbceshi.c");
        fileusbname.open(QFile::ReadOnly);

		QString re;
        QString nullspace;
        QString tmp;

		while(!fileusbname.atEnd()) {
	
			i++;
			
            re.clear();
            nullspace.clear();
            setpathsd.clear();

			re.append("/media/");  //u盘挂载的目录

			tmp=(fileusbname.readLine());
	
            for(int tmpi=0; tmpi<tmp.length(); tmpi++){
                if(tmp.at(tmpi)!='\n')
                    nullspace.append(tmp.at(tmpi));
            }
            qDebug()<<"nullspace:"<<nullspace;
			
            re.append(nullspace);
            qDebug("i=%d",i);
            re.append("/usb_test.c");
            qDebug()<<re;

            QFile filesdusb(re);
            filesdusb.open(QFile::WriteOnly);

			QTextStream s1(&filesdusb);
            s1<<"wq_hard_test_usb_by_crl6";
            filesdusb.close();
          //  sleep(1);
            system("sync");
            usleep(300);

            QFile filesdusbr(re);
           // if(filesdusbr.exists())
               // qDebug("hava");
            filesdusbr.open(QFile::ReadOnly);
            setpathsd=filesdusbr.readAll();

			QFile::remove(re);   //读完及时删除，防指文件残留在U盘里

			qDebug()<<setpathsd;

			if(setpathsd.contains("wq_hard_test_usb_by_crl6")){
                QDialog * setdialog = new QDialog;
                QLabel * settmp = new QLabel;
                settmp->setStyleSheet("color:green;");
                if( ((WIDGET_W_Info==WIDGET_W_10g) && (ij==3)) || \
					((WIDGET_W_Info==WIDGET_W_7g) && (ij==2)) || \
					((WIDGET_W_Info==WIDGET_W_7b) && (ij>=1))) {
                if(i==1){usbflag1=1;    		settmp->setText(tr("USB1测试成功"));}
                if(i==2){usbflag2=1;            settmp->setText(tr("USB2测试成功"));}
                if(i==3){usbflag3=1;            settmp->setText(tr("USB3测试成功"));}
                }else
                {
                    settmp->setStyleSheet("color:red;");
                    if((WIDGET_W_Info==WIDGET_W_7g) || (WIDGET_W_Info==WIDGET_W_7b))
                    settmp->setText(tr("USB测试失败(USB口没有全插入U盘)7寸2个"));
                    else
                    settmp->setText(tr("USB测试失败(USB口没有全插入U盘)10寸3个"));

                }
				
                QTimer*timer = new QTimer(setdialog);
                timer->start(800);
                connect(timer,SIGNAL(timeout()),setdialog,SLOT(close()));
                QGridLayout *tmplayout = new QGridLayout;
                tmplayout->addWidget(settmp,0,0,1,1);
                setdialog->setLayout(tmplayout);
                setdialog->setWindowFlags(Qt::FramelessWindowHint);
                setdialog->exec();

            }else{

			QDialog * setdialog = new QDialog;
            QLabel * settmp = new QLabel;

			if(i==1){usbflag1=0;            settmp->setText(tr("USB1测试失败"));}
            if(i==2){usbflag2=0;            settmp->setText(tr("USB2测试失败"));}
            if(i==3){usbflag3=0;            settmp->setText(tr("USB3测试失败"));}

            if( ((WIDGET_W_Info==WIDGET_W_10g) && (ij==3)) || \
					((WIDGET_W_Info==WIDGET_W_7g) && (ij==2))||
					((WIDGET_W_Info==WIDGET_W_7b) && (ij>=1))				);
            else {
                if((WIDGET_W_Info==WIDGET_W_7g) || (WIDGET_W_Info==WIDGET_W_7b))
                settmp->setText(tr("USB测试失败(USB口没有全插入U盘)7寸插2个usb"));
                else
                settmp->setText(tr("USB测试失败(USB口没有全插入U盘)10寸插3个usb"));
            }

            settmp->setStyleSheet("color:red;");
            QTimer*timer = new QTimer(setdialog);
            timer->start(800);
            connect(timer,SIGNAL(timeout()),setdialog,SLOT(close()));
            QGridLayout *tmplayout = new QGridLayout;
            tmplayout->addWidget(settmp,0,0,1,1);
            setdialog->setLayout(tmplayout);
            setdialog->setWindowFlags(Qt::FramelessWindowHint);
            setdialog->exec();
            }
        }

		QFile::remove("/tmp/usbceshi.c");   

		
    }
    switch (i) {
	    case 1:
	        if(sdflag && usbflag1) usb_sdQla->setChecked(true);
	        break;
	    case 2:
	        if(sdflag && usbflag1 && usbflag2) usb_sdQla->setChecked(true);
	        break;
	    case 3:
	        if(sdflag && usbflag1 && usbflag2 && usbflag3) usb_sdQla->setChecked(true);
	        break;
	    default:
			QDialog * setdialog = new QDialog;
	        QLabel * settmp = new QLabel;

			settmp->setText(tr("没有USB(U盘)"));
	        settmp->setStyleSheet("color:red;");

			QTimer*timer = new QTimer(setdialog);
	        timer->start(2000);

			connect(timer,SIGNAL(timeout()),setdialog,SLOT(close()));

			QGridLayout *tmplayout = new QGridLayout;
	        tmplayout->addWidget(settmp,0,0,1,1);
	        setdialog->setLayout(tmplayout);
	        setdialog->setWindowFlags(Qt::FramelessWindowHint);
	        setdialog->exec();

			break;
    }
}


#endif



float get_time_time(const char *str)
{
	char real[8]; 
	char tab;
	int min;
	int space;
	float second;
	char m;

	sscanf(str, "%s%c%d%c%f%c", real, &tab, &min, &space, &second, &m);

	printf("real=%s  tab=%d min=%d space=%d second=%f m=%d\n", real, tab, min, space, second, m);	

	return (min*60 + second);

}


int isDigitStr(QString src)
{
    QByteArray ba = src.toLatin1();//QString 转换为 char*
     const char *s = ba.data();

    while(*s && *s>='0' && *s<='9')
    	s++;

    if (*s)
    { //不是纯数字
        return false;
    }
    else
    { //纯数字
        return true;
    }
}

long long get_file_size(const char *path)  
{  
    long filesize = -1;      

    struct stat statbuff;  

    if(::stat(path, &statbuff) < 0){  
        return filesize;  
    }else{  
        filesize = statbuff.st_size;  
    }  
    return filesize;  
}  


bool isDirExist(QString fullPath)
{
    QDir dir(fullPath);
    if(dir.exists())
    {

    	return true;
    }

    return false;
}


//#define AM335X_MMC_HOTPLUG_PATH 	"/sys/devices/ocp/48060000.mmc/mmc_host/mmc0/mmc0:b368/block/mmcblk0/mmcblk0p1"
#define AM335X_MMC_HOTPLUG_PATH 	"/sys/devices/ocp/48060000.mmc/mmc_host/mmc0/"
#define AM335X_USB1_HOTPLUG_PATH	"/sys/devices/ocp/47400000.usb/47401c00.usb/musb-hdrc.1.auto/usb1/1-1/1-1.2/1-1.2:1.0"
#define AM335X_USB2_HOTPLUG_PATH	"/sys/devices/ocp/47400000.usb/47401c00.usb/musb-hdrc.1.auto/usb1/1-1/1-1.4/1-1.4:1.0" 

void CeshiSettings::usb_sd()
{
	int flag_mmc = 0;
	int flag_usb1 = 0;
	int flag_usb2 = 0;
#if 0
	if(isDirExist(QString(AM335X_MMC_HOTPLUG_PATH)))
	{
		qDebug("mmc is exist");
		flag_mmc = 1;
	}
#else
	QDir dir(AM335X_MMC_HOTPLUG_PATH);							//如果不加地址，则就在当前目录下遍历	
//	QStringList filters;  
//	filters << "*.cpp"<<"*.h";			//设置过滤类型	
//	dir.setNameFilters(filters);		//设置文件名的过滤	
	QFileInfoList list = dir.entryInfoList();  
	if(list.length() != 0)  
		for (int i = 0; i < list.size(); ++i)  
		{  
			qDebug() << list.at(i).fileName();
			if(list.at(i).fileName().contains("mmc0:"))
				flag_mmc = 1;
			
		}  
	else  
	{  
		qDebug()<<"no file";  
	}  


#endif
	if(isDirExist(QString(AM335X_USB1_HOTPLUG_PATH)))
	{
		qDebug("mmc is exist");
		flag_usb1 = 1;
	}

	if(isDirExist(QString(AM335X_USB2_HOTPLUG_PATH)))
	{
		qDebug("mmc is exist");
		flag_usb2 = 1;
	}

	if((flag_mmc | flag_usb1 | flag_usb2) == 0){
		QMessageBox::information(NULL, tr("提示"), QString("当前没有 U盘 或 SD卡!!!"));
		usb_sdQla->setChecked(false);
	}
    else{
		QMessageBox::information(NULL, tr("提示"), QString("当前U盘=%1个 SD卡=%2张").arg(flag_usb1+flag_usb2).arg(flag_mmc));
		usb_sdQla->setChecked(true);
	}
	
}

void CeshiSettings::wangka()
{
	wangkacount=0;
	wifiorwangka=0;
	system("rm /tmp/wangka.c ");
	system("cp /etc/init.d/net_sh /etc/init.d/ceshinet_sh");
	system("sync");
	qDebug("crl6 clean");
	qDebug("wangka clean");
	wangkaiptmp.clear();
	QString pingfinal;
	pingfinal.append("ping -I ");

	if(1){
	QDialog * setdialog = new QDialog;
	QLabel * settmp = new QLabel;
	settmp->setText(tr("请获取动态IP并点击关闭"));
	settmp->setStyleSheet("color:green;");
	QTimer*timer = new QTimer(setdialog);
	timer->start(4000);
	connect(timer,SIGNAL(timeout()),setdialog,SLOT(close()));
	QGridLayout *tmplayout = new QGridLayout;
	tmplayout->addWidget(settmp,0,0,1,1);
	setdialog->setLayout(tmplayout);
	setdialog->setWindowFlags(Qt::FramelessWindowHint);
	setdialog->exec();
	NetSettings netSettings;
	netSettings.setStyleSheet(this->readSubQss());
	netSettings.setGeometry(0, 0, int_WIDGET_W, int_WIDGET_H);
	netSettings.exec();
	}

	if(1){
        QFile::remove("/tmp/ceshinetislinkok.c");
        system("ifconfig eth0 > /tmp/ceshinetislinkok.c");
        QFile filetmplink("/tmp/ceshinetislinkok.c");
        filetmplink.open(QFile::ReadOnly);
        QString stmp =filetmplink.readAll();
        QString stmp2="Mask:";
        QString stmp3="Bcast:";
        
        if(stmp.contains(stmp2) && stmp.contains(stmp3)) {
            //netlianflag=0;
            QString address;

			QList<QNetworkInterface> tmplist = QNetworkInterface::allInterfaces();  
         
	        foreach(QNetworkInterface interface, tmplist)  //获取所有网络接口的列表 
	      	{ 
	            qDebug() << "Device: "<<interface.name();   //遍历每一个网络接口  
	           	if(interface.name().contains("eth"))
	 			{
	            
	            	QList<QNetworkAddressEntry> entryList =interface.addressEntries();  //硬件地址  
	       
	           		foreach(QNetworkAddressEntry entry,entryList)   //获取IP地址条目列表，每个条目中包含一个IP地址，一个子网掩码和一个广播地址                        遍历每一个IP地址条目 
	           		{ 
	               		qDebug()<<"IP Address: "<<entry.ip().toString();  //IP地址  
	               
	 					address = entry.ip().toString();
	          		}  
	          	}
	 	  	} 
    	
			
	        QString tmp;
	        for(int i = 0;i<address.length();i++)
	        {
	           if(address[i]>='0' && address[i] <='9')
	            tmp.append(address[i]);
	        }
	        QByteArray ba = tmp.toLatin1();
	        const char *s = ba.data();
	        while(*s && *s >= '0' && *s <= '9')//huo qu dong tai ip shi bai fan hui yi chang chuan zi mu shi bu xian shi
	            s++;
	        if(*s)
	            ;
	        else{
	          if( (address.length()<15) && (address !="192.168.1.16") ) //huo qu dong tai ip shi bai fan hui yi chang chuan zi mu shi bu xian shi
	//               Dip ->setText(address);
	              ;;
	        }
	        
            pingfinal.append(address);
        }
	}

	pingfinal.append(" www.baidu.com -c 3 > /tmp/wangka.c");

	qDebug()<<pingfinal;
	system("rm /tmp/wangkaceshipelate_sh");
	system("sync");
	QFile filetmptt("/tmp/wangkaceshipelate_sh");
	filetmptt.open(QFile::WriteOnly);
	QTextStream stmptt(&filetmptt);
	stmptt<<"#!/bin/sh"<<"\n";
	stmptt<<pingfinal;
	stmptt<<"\n";
	stmptt<<"sync"<<"\n";
	filetmptt.close();
	system("sync");
	system("chmod +x /tmp/wangkaceshipelate_sh");
	QProcess *proc =new QProcess;
	proc->start("/tmp/wangkaceshipelate_sh");		// fei zu sai

	PleasWait wangkaliantmp;
	wangkaliantmp.show();
	
	if(wangkarate>10 || (wangkaiptmp.isNull()) ){

		QDialog * setdialog = new QDialog;
		QLabel * settmp = new QLabel;
		settmp->setText(tr("有线网测试失败"));
		settmp->setStyleSheet("color:red;");
		QTimer*timer = new QTimer(setdialog);
		timer->start(600);
		connect(timer,SIGNAL(timeout()),setdialog,SLOT(close()));
		QGridLayout *tmplayout = new QGridLayout;
		tmplayout->addWidget(settmp,0,0,1,1);
		setdialog->setLayout(tmplayout);
		setdialog->setWindowFlags(Qt::FramelessWindowHint);
		setdialog->exec();
		wangkaQla->setChecked(false);
	}else{

		QDialog * setdialog = new QDialog;
		QLabel * settmp = new QLabel;
		settmp->setText(tr("有线网测试成功"));
		settmp->setStyleSheet("color:green;");
		QTimer*timer = new QTimer(setdialog);
		timer->start(3000);
		connect(timer,SIGNAL(timeout()),setdialog,SLOT(close()));
		QGridLayout *tmplayout = new QGridLayout;
		tmplayout->addWidget(settmp,0,0,1,1);
		setdialog->setLayout(tmplayout);
		setdialog->setWindowFlags(Qt::FramelessWindowHint);
		setdialog->exec();
		wangkaQla->setChecked(true);
	}

 system("rm  /etc/init.d/net_sh ");
 system("cp /etc/init.d/ceshinet_sh /etc/init.d/net_sh ");
 system("sync");
}


void CeshiSettings::beef()
{

    WeiqianFunctions::Beep();
    tmpitem=5;
    TmpDialog beefDialog ;
    beefDialog.show();
    if(beefSuccessFlag)
    beefQla->setChecked(true);
    else
    beefQla->setChecked(false);
}

void CeshiSettings::beiguang()
{
    QDialog * setdialog = new QDialog;
    QLabel * settmp = new QLabel;
    settmp->setText(tr("背光将关闭1S"));
    settmp->setStyleSheet("color:red;");
    QTimer*timer = new QTimer(setdialog);
    timer->start(600);
    connect(timer,SIGNAL(timeout()),setdialog,SLOT(close()));
    QGridLayout *tmplayout = new QGridLayout;
    tmplayout->addWidget(settmp,0,0,1,1);
    setdialog->setLayout(tmplayout);
    setdialog->setWindowFlags(Qt::FramelessWindowHint);
    setdialog->exec();

    WeiqianFunctions::SetBackLight(false);
    system("wq_pwm_app.elf /dev/wq_pwm w 1");
    system("wq_pwm_app.elf /dev/wq_pwm w 0");
    sleep(1);
    WeiqianFunctions::SetBackLight(true);
    system("wq_pwm_app.elf /dev/wq_pwm w 128");
    tmpitem=6;
    TmpDialog beiguangDialog ;
    beiguangDialog.show();
    if(beiguangSuccessFlag)
    beiguangQla->setChecked(true);
    else
    beiguangQla->setChecked(false);
}
void CeshiSettings::wifi()
{
    system("ifconfig -a | grep wlan >/tmp/ceshiHAVEwlan.dat");
    QFile filetmpwlan("/tmp/ceshiHAVEwlan.dat");
    filetmpwlan.open(QFile::ReadOnly);
    QString stmpwlan =filetmpwlan.readAll();
    QString stmp2wlan="wlan";
    int havewififlag=1;
    if(!stmpwlan.contains(stmp2wlan) ){
        havewififlag=0;
        QDialog * setdialog = new QDialog;
        QLabel * settmp = new QLabel;
        settmp->setText(tr("标配版没有WIFI模块"));
        settmp->setStyleSheet("color:red;");
        QTimer*timer = new QTimer(setdialog);
        timer->start(1000);
        connect(timer,SIGNAL(timeout()),setdialog,SLOT(close()));
        QGridLayout *tmplayout = new QGridLayout;
        tmplayout->addWidget(settmp,0,0,1,1);
        setdialog->setLayout(tmplayout);
        setdialog->setWindowFlags(Qt::FramelessWindowHint);
        setdialog->exec();
    }else  if(havewififlag) {
    wifikacount=0;
    wifiorwangka=1;
    wifikaiptmp.clear();
  //  system("ifconfig eth0 down");
   // qDebug("3000");
    QString pingfinal;
    pingfinal.append("ping -I ");

    QDialog * setdialog = new QDialog;
    QLabel * settmp = new QLabel;
    settmp->setText(tr("请连接WIFI"));
    settmp->setStyleSheet("color:green;");
    QTimer*timer = new QTimer(setdialog);
    timer->start(600);
    connect(timer,SIGNAL(timeout()),setdialog,SLOT(close()));
    QGridLayout *tmplayout = new QGridLayout;
    tmplayout->addWidget(settmp,0,0,1,1);
    setdialog->setLayout(tmplayout);
    setdialog->setWindowFlags(Qt::FramelessWindowHint);
    setdialog->exec();
    this->repaint();

    WifiSeting wifiSettings;
    wifiSettings.setStyleSheet(this->readSubQss());
    wifiSettings.setGeometry(0, 0, int_WIDGET_W, int_WIDGET_H);
    wifiSettings.exec();
/*
    QDialog * setdialog1 = new QDialog;
    QLabel * settmp1 = new QLabel;
    settmp1->setText(tr("开始测试WIFI"));
    settmp1->setStyleSheet("color:green;");
    QTimer*timer1 = new QTimer(setdialog1);
    timer1->start(800);
    connect(timer1,SIGNAL(timeout()),setdialog1,SLOT(close()));
    QGridLayout *tmplayout1 = new QGridLayout;
    tmplayout1->addWidget(settmp1,0,0,1,1);
    setdialog1->setLayout(tmplayout1);
    setdialog1->setWindowFlags(Qt::FramelessWindowHint);
    setdialog1->exec();
    this->repaint();
*/
    system("rm /tmp/wifitest.c ");
    system("sync");
    usleep(300);
  //  system("ping www.baidu.com -c 8 -s 32 > /tmp/wifitest.c");
    if(1){

        system("ifconfig wlan0 > /tmp/ceshiislinkokwifi6.c");
        QFile filetmplink("/tmp/ceshiislinkokwifi6.c");
        filetmplink.open(QFile::ReadOnly);
        QString stmp =filetmplink.readAll();
        QString stmp2="Mask:";
        QString stmp3="Bcast:";

        system("iwconfig wlan0 > /tmp/ceshiislinkokwifi6.c");
        QFile filetmplink3("/tmp/ceshiislinkokwifi6.c");
        filetmplink3.open(QFile::ReadOnly);
        QString stmp33 =filetmplink3.readAll();
        //)<<stmp33;
        QString stmp23="ESSID:off/any";

        if(stmp.contains(stmp2) && stmp.contains(stmp3) && (!stmp33.contains(stmp23)))
        {
          system("killall -9 udhcpc");
          int began=0;
          int ON =1;
          system("ifconfig wlan0 | grep \"inet addr:\" > /tmp/ceshiwifiip.c");//inet addr:192.168.23.2  Bcast:192.168.23.255  Mask:255.255.255.0
          QFile filewifi("/tmp/ceshiwifiip.c");
          filewifi.open(QIODevice::ReadWrite);
          QString str(filewifi.readAll());
          QString tmp;
          for(int i = 0;i<str.length();i++)
          {
              if(str[i]==':'){
                  i++;
                  began=1;
              }
              if(began)
              if(str[i]!=' '&& (ON) && str[i]!='B')
                 tmp.append(str[i]);
              if(str[i]=='B')
                  ON=0;
          }
         //  Dip ->setText(tmp);
          // DipWifi->setText(tmp);
       pingfinal.append(tmp);
        }

            }

    pingfinal.append(" www.baidu.com -c 3 > /tmp/wifitest.c");
    qDebug()<<pingfinal;
    system("rm /tmp/wifikaceshipelate_sh");
    system("sync");
    QFile filetmptt("/tmp/wifikaceshipelate_sh");
    filetmptt.open(QFile::WriteOnly);
    QTextStream stmptt(&filetmptt);
    stmptt<<"#!/bin/sh"<<"\n";
    stmptt<<pingfinal;
    stmptt<<"\n";
    stmptt<<"sync"<<"\n";
    filetmptt.close();
    system("sync");
    system("chmod +x /tmp/wifikaceshipelate_sh");
    QProcess *proc =new QProcess;
    proc->start("/tmp/wifikaceshipelate_sh");// fei zu sa

    PleasWait wifiliantmp;
    wifiliantmp.show();
   // char *S1;
/*    usleep(1000);
    S1 = ((pingfinal.toAscii()).data());
    qDebug("S=%s",S1);
    usleep(1000);
    system(S1);
    system("sync");
    usleep(300);*/
  /*  QFile file1ceshi("/tmp/wifitest.c");
    file1ceshi.open(QFile::ReadOnly);
    QString setpath=file1ceshi.readAll();
    file1ceshi.close();
    QString iptmp;
    QString iptmpall;
    int beganip=0;
    int stop=0;
    int rate=0;
    for(int i=0;i<setpath.length();i++)
    {
     if(setpath[i]=='i' && setpath[i+1]=='v' && setpath[i+2]=='e' && setpath[i+3]=='d'&& setpath[i+4]==','){
         beganip=1;
         i+=5;
     }
     if(beganip && setpath[i]!='%' &&setpath[i]!=' ')
         if(!stop)
      iptmp.append(setpath[i]);
     if(setpath[i]=='%')
         stop=1;
    }
    qDebug()<<iptmp;
    iptmpall.append(tr("丢包率:"));
    iptmpall.append(iptmp);
    iptmpall.append('%');
    qDebug()<<iptmpall;
    rate=iptmp.toInt();
    qDebug("rate=%d",rate);*/

    if( (wifikarate>10) || (wifikaiptmp.isNull())){

        QDialog * setdialog = new QDialog;
        QLabel * settmp = new QLabel;
        settmp->setText(tr("wif测试失败"));
        settmp->setStyleSheet("color:red;");
        QTimer*timer = new QTimer(setdialog);
        timer->start(600);
        connect(timer,SIGNAL(timeout()),setdialog,SLOT(close()));
        QGridLayout *tmplayout = new QGridLayout;
        tmplayout->addWidget(settmp,0,0,1,1);
        setdialog->setLayout(tmplayout);
        setdialog->setWindowFlags(Qt::FramelessWindowHint);
        setdialog->exec();
        wifiQla->setChecked(false);
    }else{

        QDialog * setdialog = new QDialog;
        QLabel * settmp = new QLabel;
        settmp->setText(tr("wifi测试成功"));
        settmp->setStyleSheet("color:green;");
        QTimer*timer = new QTimer(setdialog);
        timer->start(600);
        connect(timer,SIGNAL(timeout()),setdialog,SLOT(close()));
        QGridLayout *tmplayout = new QGridLayout;
        tmplayout->addWidget(settmp,0,0,1,1);
        setdialog->setLayout(tmplayout);
        setdialog->setWindowFlags(Qt::FramelessWindowHint);
        setdialog->exec();
        wifiQla->setChecked(true);
    }
 //system("ifconfig eth0 up");
 } else {

    }
}
void CeshiSettings::can()
{
    system("ifconfig -a | grep can >/tmp/ceshiHAVEcan.dat");
    QFile filetmpwlan("/tmp/ceshiHAVEcan.dat");
    filetmpwlan.open(QFile::ReadOnly);
    QString stmpwlan =filetmpwlan.readAll();
    QString stmp2wlan="can";
    int havewififlag=1;
    if(!stmpwlan.contains(stmp2wlan) ){
        havewififlag=0;
        QDialog * setdialog = new QDialog;
        QLabel * settmp = new QLabel;
        settmp->setText(tr("标配版没有CAN模块"));
        settmp->setStyleSheet("color:red;");
        QTimer*timer = new QTimer(setdialog);
        timer->start(1000);
        connect(timer,SIGNAL(timeout()),setdialog,SLOT(close()));
        QGridLayout *tmplayout = new QGridLayout;
        tmplayout->addWidget(settmp,0,0,1,1);
        setdialog->setLayout(tmplayout);
        setdialog->setWindowFlags(Qt::FramelessWindowHint);
        setdialog->exec();
    }else  if(havewififlag) {

 WeiqianTools wqTools;
 wqTools.pTextTab->setCurrentIndex(1);
 wqTools.setStyleSheet(this->readSubQss());
 wqTools.setGeometry(0, 0, int_WIDGET_W, int_WIDGET_H);
 wqTools.exec();
 tmpitem=1;
 TmpDialog canDialog ;
 canDialog.show();
 if(canSuccessFlag)
 canQla->setChecked(true);
 else
 canQla->setChecked(false);
    }
}
QString CeshiSettings::readSubQss()
{
    QString iconQssStr;
    QString sizeQssStr;
    if(g_lcdsize == LCDSIZE_1024x768 || g_lcdsize == LCDSIZE_1280x800){
        QFile sizeQss(":/qss/linuxdesktop/stylesheet/subwidgetsize_1024x768.qss");
        QFile iconQss(":/qss/linuxdesktop/stylesheet/subwidgeticon_1024x768.qss");
        sizeQss.open(QFile::ReadOnly);
        sizeQssStr = sizeQss.readAll();

        iconQss.open(QFile::ReadOnly);
        iconQssStr = iconQss.readAll();
    }else if(g_lcdsize == LCDSIZE_800x600){
		QFile sizeQss(":/qss/linuxdesktop/stylesheet/subwidgetsize_800x600.qss");
		sizeQss.open(QFile::ReadOnly);
		sizeQssStr = sizeQss.readAll();

		QFile iconQss(":/qss/linuxdesktop/stylesheet/subwidgeticon_800x600.qss");
		iconQss.open(QFile::ReadOnly);
		iconQssStr = iconQss.readAll();
    }else   if(g_lcdsize == LCDSIZE_800x480){
		QFile sizeQss(":/qss/linuxdesktop/stylesheet/subwidgetsize7b.qss");
		sizeQss.open(QFile::ReadOnly);
		sizeQssStr = sizeQss.readAll();
		QFile iconQss(":/qss/linuxdesktop/stylesheet/subwidgeticon7b.qss");
		iconQss.open(QFile::ReadOnly);
		iconQssStr = iconQss.readAll();
    }else   if(g_lcdsize == LCDSIZE_480x272){
		QFile sizeQss(":/qss/linuxdesktop/stylesheet/subwidgetsize_480x272.qss");
		sizeQss.open(QFile::ReadOnly);
		sizeQssStr = sizeQss.readAll();
		QFile iconQss(":/qss/linuxdesktop/stylesheet/subwidgeticon_480x272.qss");
		iconQss.open(QFile::ReadOnly);
		iconQssStr = iconQss.readAll();
    }

    return (sizeQssStr + iconQssStr);

}

CeshiSettings::~CeshiSettings()
{
    if(m_pReadThread1->isRunning()) {
        m_pReadThread1->stop();
        usleep(100000);
    }
    if(m_pReadThread2->isRunning()) {
        m_pReadThread2->stop();
        usleep(100000);
    }
    if(m_pReadThread3->isRunning()) {
        m_pReadThread3->stop();
        usleep(100000);
    }
    if(m_pReadThread4->isRunning()) {
        m_pReadThread4->stop();
        usleep(100000);
    }
     bpMySerialPort1->close();
     bpMySerialPort2->close();
     bpMySerialPort3->close();
     bpMySerialPort4->close();

     if(!DebugOrRelease)
     	QWSServer::setCursorVisible(false);
}
